<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="待审核" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<view class="list">
			<view class="apply">
				<text>申请人:</text>
				<text>{{teacher}}</text>
			</view>
			<view class="service_time">
				<view class="use">
					<text>使用时间</text>
				</view>
				<view class="time">
					<view class="top">
						<text>{{start_date}}</text>
					</view>
					<view class="bottom">
						<text>{{end_date}}</text>
					</view>
				</view>
			</view>
			<view class="vehicle">
				<text>车辆</text>
				<view class="select">
					<text>{{obj?obj.name:''}}</text>
					<text></text>
				</view>
			</view>
			<view class="blank" style="width: 100%; height: 18rpx;">
			</view>
			<view class="vehicle_info">
				<view class="license">
					<text>车牌号码:</text>
					<text>{{obj?obj.no:''}}</text>
					<text>司机:</text>
					<text>{{obj?obj.driver_name:''}}</text>
				</view>
				<view class="available">
					<text>可载人数:</text>
					<text>{{obj?obj.people:''}}</text>
					<text>电话:</text>
					<text>{{obj?obj.driver_phone:''}}</text>
				</view>
				<view class="picture">
					<view class="photo">
						<text>图片</text>
					</view>
					<view class="photo_list">
						<image :src="item" mode="widthFix" v-for="(item,index) in img_arr" :key="index"></image>
					</view>
				</view>
				<view class="" style="width: 100%; height: 30rpx;">

				</view>
			</view>
			<view class=" " style="width: 94%; margin-left: 3%; height: 30rpx; border-bottom:1rpx solid #F2F2F2;">

			</view>
			<view class="event">
				<text>事件</text>
				<text>{{event}}</text>
			</view>
			<view class="result">
				<text class="accept">受理结果</text>
				<view id="toggle">
					<text id="passed" :style="{color:left_color,background:left_background_color}"
						@click="changeLeftColor">通过</text>
					<text id="reject" :style="{color:right_color,background:right_background_color}"
						@click="changeRightColor">驳回</text>
				</view>
			</view>
			<view class="remarks">
				审核备注
			</view>
			<view class=""
				style="width:94%; height:15rpx; margin-left:3%; background:#F2F2F2; border-top-left-radius:12rpx; border-top-right-radius:12rpx;">

			</view>
			<textarea value="" v-model="form.handle_remark" placeholder="单行输入"
				style="width:94%; height:160rpx; margin-left:3%; background:#F2F2F2; text-indent:1em; border-bottom-left-radius:12rpx; border-bottom-right-radius:12rpx;" />
			<view class="" style="width:100%; height:25rpx; background:#fff;">
			</view>
		</view>
		<view class="confirm">
			<view class="verify" @click="applyHandle">
				{{verify}}
			</view>
		</view>
	</view>
</template>

<script>
	import time from '../../time.js'
	import request from '../../request.js'
	export default {
		data() {
			return {
				left_color: '#fff',
				left_background_color: '#2E98FA',
				verify: '确认',
				right_color: '#333333',
				content: '',
				right_background_color: '#F2F2F2',
				delivery_obj: {},
				img_arr: [],
				teacher: '',
				event: '',
				start_date: '',
				end_date: '',
				obj: {

				},
				form: {
					apply_id: '',
					handle: 1,
					handle_remark: '',
				},

			}
		},
		onLoad(option) {
			if (option.obj) {
				this.delivery_obj = JSON.parse(decodeURIComponent(option.obj));
				console.log(this.delivery_obj);
				console.log(option.obj);
				this.form.apply_id = this.delivery_obj.apply_id;
				this.obj = this.delivery_obj.car_info ? this.delivery_obj.car_info : null;
				this.teacher = this.delivery_obj.teacher_info ? this.delivery_obj.teacher_info.full_name : '';
				let arr = this.delivery_obj.car_info ? this.delivery_obj.car_info.pics.split(',') : [];
				this.img_arr = arr;
				this.event = this.delivery_obj.event;
				this.start_date = time.format(this.delivery_obj.start_time);
				this.end_date = time.format(this.delivery_obj.end_time);
			}
		},
		methods: {
			changeLeftColor() {
				if (this.left_background_color == '#2E98FA') {
					this.left_color = '#333333';
					this.left_background_color = '#F2F2F2';
					this.right_color = '#fff';
					this.right_background_color = '#2E98FA';
				} else {
					this.left_color = '#fff';
					this.left_background_color = '#2E98FA';
					this.form.handle = 1;
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
				}
			},
			changeRightColor() {
				if (this.right_background_color == '#2E98FA') {
					this.right_color = '#333333';
					this.right_background_color = '#F2F2F2';
					this.left_color = '#fff';
					this.left_background_color = '#2E98FA';
				} else {
					this.right_color = '#fff';
					this.right_background_color = '#2E98FA';
					this.left_color = '#333333';
					this.form.handle = 2;
					this.left_background_color = '#F2F2F2';
				}
			},
			applyHandle() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/carApply/applyHandle',
					method: 'post',
					data: {
						...this.form,
					},
					success(res) {
						if (res.statusCode == 200) {
							_this.$toLink('../teacher_car/teacher_car', {}, 2)
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
		}

	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		height: 100vh;
		background-color: #F2F2F2;
		overflow: hidden;

		.list {
			width: 100%;
			background-color: #fff;
			margin-top: 30rpx;

			.apply {
				width: 94%;
				margin-left: 3%;
				height: 88rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				border-bottom: 1rpx solid #F2F2F2;


				text {
					color: #333333;
					font-size: 30rpx;

					&:nth-child(1) {}

					&:nth-child(2) {
						margin-left: 5rpx;
					}
				}
			}

			.service_time {
				width: 94%;
				margin-left: 3%;
				height: 134rpx;
				display: flex;
				justify-content: flex-start;

				.use {
					width: 120rpx;
					height: 134rpx;
					display: flex;
					justify-content: flex-start;

					text {
						&:nth-child(1) {
							color: #666666;
							font-size: 26rpx;
							margin-top: 31rpx;
						}
					}
				}

				.time {
					margin-top: 28rpx;
					margin-left: 24rpx;
					width: 400rpx;
					height: 134rpx;

					.top {
						height: 28rpx;
						width: 100%;
						display: flex;
						justify-content: flex-start;

						text {
							color: #333333;
							font-size: 26rpx;
							height: 28rpx;

							&:nth-child(1) {
								width: 400rpx;
							}
						}
					}

					.bottom {
						height: 28rpx;
						margin-top: 20rpx;
						width: 100%;
						display: flex;
						justify-content: flex-start;

						text {
							color: #333333;
							font-size: 26rpx;
							height: 28rpx;

							&:nth-child(1) {
								width: 400rpx;
							}
						}
					}

				}
			}

			.vehicle {
				width: 94%;
				margin-left: 3%;
				height: 52rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				text {
					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
						height: 28rpx;
						width: 130rpx;
					}
				}

				.select {
					width: 285rpx;
					height: 50rpx;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					border: 1rpx solid #F2F2F2;
					margin-left: 10rpx;

					text {
						&:nth-child(1) {
							width: 200rpx;
							color: #333333;
							font-size: 26rpx;
							height: 30rpx !important;
							line-height: 30rpx;
							margin-left: 10rpx;
						}

						&:nth-child(2) {
							width: 0rpx;
							height: 0rpx;
							margin-top: 15rpx;
							margin-left: 20rpx;
							border-width: 14rpx 14rpx 14rpx 14rpx;
							border-color: #ccc transparent transparent transparent;
							border-style: solid;
						}
					}
				}
			}

			.vehicle_info {
				width: 94%;
				margin-left: 3%;
				background-color: #F2F2F2;
				border-radius: 8rpx;

				.license {
					width: 100%;
					display: flex;
					justify-content: flex-start;
					height: 52rpx;

					text {
						color: #333333;
						font-size: 26rpx;
						height: 28rpx;
						margin-top: 22rpx;

						&:nth-child(1) {
							width: 130rpx;
							margin-left: 15rpx;
						}

						&:nth-child(2) {
							width: 150rpx;
						}

						&:nth-child(3) {
							margin-left: 80rpx;
							width: 95rpx;
						}

						&:nth-child(4) {}
					}
				}

				.available {
					width: 100%;
					height: 52rpx;
					display: flex;
					justify-content: flex-start;

					text {
						color: #333333;
						font-size: 26rpx;
						height: 28rpx;
						margin-top: 22rpx;

						&:nth-child(1) {
							width: 130rpx;
							margin-left: 15rpx;
						}

						&:nth-child(2) {
							width: 150rpx;
						}

						&:nth-child(3) {
							margin-left: 80rpx;
							width: 95rpx;
						}

						&:nth-child(4) {}
					}
				}

				.picture {
					width: 100%;
					display: flex;
					justify-content: flex-start;
					margin-top: 25rpx;

					.photo {
						width: 80rpx;
						display: flex;
						justify-content: flex-start;

						text {
							&:nth-child(1) {
								color: #333333;
								font-size: 26rpx;
								margin-left: 15rpx;
							}
						}
					}

					.photo_list {
						flex-wrap: wrap;
						width: 450rpx;
						display: flex;
						justify-content: flex-start;

						image {
							width: 163rpx;

							&:nth-child(n+1) {
								margin-left: 24rpx;
							}
						}
					}

				}
			}

			.event {
				width: 94%;
				height: 60rpx;
				margin-left: 3%;
				display: flex;
				justify-content: flex-start;

				text {
					color: #666666;
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 20rpx;
					width: 150rpx;

					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
						height: 28rpx;
						margin-top: 20rpx;
						width: 150rpx;
					}

					&:nth-child(2) {
						font-size: 26rpx;
						margin-top: 20rpx;
						width: 450rpx;
						color: #333333;
						overflow: hidden;
					}
				}
			}

			.result {
				width: 94%;
				margin-left: 3%;
				height: 100rpx;
				display: flex;
				justify-content: flex-start;

				.accept {
					height: 28rpx;
					width: 150rpx;
					font-size: 26rpx;
					color: #666666;
					margin-top: 38rpx;
				}

				#toggle {
					width: 200rpx;
					height: 40rpx;
					margin-top: 35rpx;
					position: relative;

					#passed {
						width: 80rpx;
						height: 40rpx;
						color: #fff;
						text-align: center;
						border-top-left-radius: 20rpx;
						position: absolute;
						left: 0rpx;
						top: 0rpx;
						border-bottom-left-radius: 20rpx;
						background-color: #2D82FF;
						line-height: 40rpx;
						font-size: 20rpx;
					}

					#reject {
						width: 80rpx;
						height: 40rpx;
						color: #333333;
						position: absolute;
						left: 80rpx;
						top: 0rpx;
						text-align: center;
						border-top-right-radius: 20rpx;
						border-bottom-right-radius: 20rpx;
						background-color: #F2F2F2;
						line-height: 40rpx;
						font-size: 20rpx;
					}
				}
			}

			.remarks {
				width: 94%;
				height: 60rpx;
				margin-left: 3%;
				display: flex;
				justify-content: flex-start;
				font-size: 26rpx;
				color: #666666;

			}
		}

		.confirm {
			width: 100%;
			height: 200rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.verify {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: linear-gradient(to right, #2C78FE, #32B0FF);
				color: #fff;
				font-size: 30rpx;
			}
		}

	}
</style>
